package com.kgc.xsProvider.service.ServiceImpl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.kgc.basic.util.PageInfo;
import com.kgc.basic.util.ResponseMsg;
import com.kgc.xs.pojo.SalesOrderExecutionStatus;
import com.kgc.xsProvider.dao.SalesOrderExecutionStatusMapper;
import com.kgc.xsProvider.service.SalesOrderExecutionStatusService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class SalesOrderExecutionStatusServiceImpl implements SalesOrderExecutionStatusService {

    private Logger logger = LoggerFactory.getLogger(SalesOrderExecutionStatusServiceImpl.class);

    @Autowired
    private SalesOrderExecutionStatusMapper salesOrderExecutionStatusMapper;

    @Override
    public ResponseMsg selectSalesOrderExecutionStatusByPage(Map<String, Object> params) {
        logger.info("SalesOrderExecutionStatusServiceImpl selectByPage params:{}", params);
        ResponseMsg msg = new ResponseMsg();
        PageInfo<SalesOrderExecutionStatus> pageInfo = new PageInfo<>();
        pageInfo.setPageNo(params.get("pageNo") == null ? 1 : Integer.parseInt(params.get("pageNo").toString()));
        pageInfo.setPageSize(params.get("pageSize") == null ? 10 : Integer.parseInt(params.get("pageSize").toString()));
        Page page = PageHelper.startPage(pageInfo.getPageNo(), pageInfo.getPageSize());
        List<SalesOrderExecutionStatus> salesOrderExecutionStatusList = salesOrderExecutionStatusMapper.selectSalesOrderExecutionStatusByPage(params);
        pageInfo.setList(salesOrderExecutionStatusList);
        pageInfo.setTotal((int) page.getTotal());
        msg.setData(pageInfo);
        return msg;
    }
}
